{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Imports\n",
    "\n",
    "Import all the modules and functionalities we need."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "\n",
    "# Import standard libraries.\n",
    "import os\n",
    "\n",
    "# Import third party libraries.\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "from statsmodels.stats.multitest import multipletests\n",
    "\n",
    "# Import custom libraries/scripts.\n",
    "import annotations\n",
    "import helpers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Loading data\n",
    "\n",
    "Fetch all our relevant data for the current analysis."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set working contants.\n",
    "EXPERIMENTS_PATH = r'\\\\10.40.12.80\\home\\PhD\\Results\\Competition\\DL\\small_arenas\\territory\\24h_mated\\processed'\n",
    "FPS = 60\n",
    "N_MINUTES = 15\n",
    "N_FRAMES = N_MINUTES * 60 * FPS\n",
    "INK = 'black'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set figure configurations.\n",
    "sns.set(\n",
    "        context='paper',\n",
    "        style='ticks',\n",
    "        font='sans-serif',\n",
    "        font_scale=1.0, \n",
    "        rc={\n",
    "            'axes.axisbelow': True,\n",
    "            'axes.edgecolor': INK,\n",
    "            'axes.facecolor': 'white' if INK=='black' else 'black',\n",
    "            'axes.grid': False,\n",
    "            'axes.labelcolor': INK,\n",
    "            'axes.labelsize': 13.0,\n",
    "            'axes.labelweight': 'normal',\n",
    "            'axes.linewidth': 1.0,\n",
    "            'axes.spines.left': True,\n",
    "            'axes.spines.bottom': True,\n",
    "            'axes.spines.top': False,\n",
    "            'axes.spines.right': False,\n",
    "            'axes.titlepad': 15.0,\n",
    "            'axes.titlesize': 20.0,\n",
    "            'axes.titleweight': 'bold',\n",
    "            'figure.facecolor': 'white' if INK=='black' else 'black',\n",
    "            'figure.figsize': [6.0, 4.0],\n",
    "            'figure.titlesize': 30.0,\n",
    "            'figure.titleweight': 'bold',\n",
    "            'font.family': ['sans-serif'],\n",
    "            'font.sans-serif': ['Arial'],\n",
    "            'legend.frameon': False,\n",
    "            'legend.fontsize': 11.0,\n",
    "            'lines.color': INK,\n",
    "            'lines.linewidth': 1.0,\n",
    "            'patch.edgecolor': INK,\n",
    "            'savefig.dpi': 300,\n",
    "            'savefig.format': 'png',\n",
    "            'savefig.bbox': 'tight',\n",
    "            'savefig.transparent': True,\n",
    "            'text.color': INK,\n",
    "            'text.usetex': False,\n",
    "            'xtick.color': INK,\n",
    "            'xtick.direction': 'out',\n",
    "            'xtick.labelsize': 12.0,\n",
    "            'xtick.major.pad': 5.0,\n",
    "            'xtick.major.size': 0.0,\n",
    "            'xtick.major.width': 1.0,\n",
    "            'xtick.minor.size': 0.0,\n",
    "            'xtick.minor.width': 0.4,\n",
    "            'ytick.color': INK,\n",
    "            'ytick.direction': 'out',\n",
    "            'ytick.labelsize': 12.0,\n",
    "            'ytick.major.pad': 5.0,\n",
    "            'ytick.major.size': 3.0,\n",
    "            'ytick.major.width': 1.0,\n",
    "            'ytick.minor.size': 0.0,\n",
    "            'ytick.minor.width': 0.4\n",
    "           }\n",
    "       )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Folder already exists, skipping.\n"
     ]
    }
   ],
   "source": [
    "# Prepare the Figures folder to save our graphs in.\n",
    "savepath = os.path.join(r'C:\\Users\\Miguel\\Desktop\\paper_data', 'paper_figures', 'figure4')\n",
    "try:\n",
    "    os.makedirs(savepath)\n",
    "    print('New folder created.')\n",
    "except FileExistsError:\n",
    "    print('Folder already exists, skipping.')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Paths to conditions:\n",
      " ['\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor', '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\nothing']\n"
     ]
    }
   ],
   "source": [
    "# Set the conditions to analyze.\n",
    "condition_order = ['food_odor', 'nothing']\n",
    "conditions = [item.path for item in os.scandir(EXPERIMENTS_PATH) if item.name in condition_order]\n",
    "print('Paths to conditions:\\n', conditions)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\t\n",
      " food_odor\n",
      "\t\n",
      " nothing\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'food_odor': ['\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor\\\\video_2022-05-25T12_07_57_arena16.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor\\\\video_2022-06-08T10_59_11_arena2.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor\\\\video_2022-06-08T10_59_11_arena5.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor\\\\video_2022-06-08T10_59_11_arena7.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor\\\\video_2022-06-08T11_21_49_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor\\\\video_2022-06-08T11_21_49_arena12.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor\\\\video_2022-06-08T11_21_49_arena14.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor\\\\video_2022-06-08T11_50_31_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor\\\\video_2022-06-08T11_50_31_arena16.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor\\\\video_2022-06-09T12_04_14_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor\\\\video_2022-06-09T12_04_14_arena12.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor\\\\video_2022-06-09T12_04_14_arena3.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor\\\\video_2022-06-09T12_04_14_arena4.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor\\\\video_2022-06-09T12_04_14_arena8.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor\\\\video_2022-06-09T12_35_55_arena13.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor\\\\video_2022-06-09T12_35_55_arena14.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor\\\\video_2022-06-09T12_35_55_arena6.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\food_odor\\\\video_2022-06-09T12_35_55_arena9.csv'],\n",
       " 'nothing': ['\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\nothing\\\\video_2022-05-25T11_34_25_arena16.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\nothing\\\\video_2022-05-25T12_07_57_arena8.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\nothing\\\\video_2022-06-08T10_59_11_arena16.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\nothing\\\\video_2022-06-08T10_59_11_arena4.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\nothing\\\\video_2022-06-08T10_59_11_arena8.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\nothing\\\\video_2022-06-08T11_21_49_arena13.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\nothing\\\\video_2022-06-08T11_21_49_arena5.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\nothing\\\\video_2022-06-08T11_21_49_arena9.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\nothing\\\\video_2022-06-08T11_50_31_arena14.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\nothing\\\\video_2022-06-08T11_50_31_arena15.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\nothing\\\\video_2022-06-08T11_50_31_arena3.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\nothing\\\\video_2022-06-09T12_04_14_arena13.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\nothing\\\\video_2022-06-09T12_04_14_arena15.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\territory\\\\24h_mated\\\\processed\\\\nothing\\\\video_2022-06-09T12_35_55_arena3.csv']}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Load all usable experiments for each condition.\n",
    "experiments = {condition: [] for condition in condition_order}\n",
    "\n",
    "for condition_path in conditions:\n",
    "    \n",
    "    condition = os.path.basename(condition_path)\n",
    "    print('\\t\\n', condition)\n",
    "    \n",
    "    for item in os.scandir(condition_path):\n",
    "        if item.name.endswith('.csv'):\n",
    "            \n",
    "            annotation_video = annotations.read(item.path)\n",
    "            \n",
    "            experiments[condition].append(item.path)\n",
    "\n",
    "experiments"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Aggression Analysis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 0 \n",
      "Experiment: video_2022-05-25T12_07_57_arena16 \n",
      "Condition: food_odor \n",
      "\n",
      "Iteration: 1 \n",
      "Experiment: video_2022-06-08T10_59_11_arena2 \n",
      "Condition: food_odor \n",
      "\n",
      "Iteration: 2 \n",
      "Experiment: video_2022-06-08T10_59_11_arena5 \n",
      "Condition: food_odor \n",
      "\n",
      "Iteration: 3 \n",
      "Experiment: video_2022-06-08T10_59_11_arena7 \n",
      "Condition: food_odor \n",
      "\n",
      "Iteration: 4 \n",
      "Experiment: video_2022-06-08T11_21_49_arena11 \n",
      "Condition: food_odor \n",
      "\n",
      "Iteration: 5 \n",
      "Experiment: video_2022-06-08T11_21_49_arena12 \n",
      "Condition: food_odor \n",
      "\n",
      "Iteration: 6 \n",
      "Experiment: video_2022-06-08T11_21_49_arena14 \n",
      "Condition: food_odor \n",
      "\n",
      "Iteration: 7 \n",
      "Experiment: video_2022-06-08T11_50_31_arena11 \n",
      "Condition: food_odor \n",
      "\n",
      "Iteration: 8 \n",
      "Experiment: video_2022-06-08T11_50_31_arena16 \n",
      "Condition: food_odor \n",
      "\n",
      "Iteration: 9 \n",
      "Experiment: video_2022-06-09T12_04_14_arena11 \n",
      "Condition: food_odor \n",
      "\n",
      "Iteration: 10 \n",
      "Experiment: video_2022-06-09T12_04_14_arena12 \n",
      "Condition: food_odor \n",
      "\n",
      "Iteration: 11 \n",
      "Experiment: video_2022-06-09T12_04_14_arena3 \n",
      "Condition: food_odor \n",
      "\n",
      "Iteration: 12 \n",
      "Experiment: video_2022-06-09T12_04_14_arena4 \n",
      "Condition: food_odor \n",
      "\n",
      "Iteration: 13 \n",
      "Experiment: video_2022-06-09T12_04_14_arena8 \n",
      "Condition: food_odor \n",
      "\n",
      "Iteration: 14 \n",
      "Experiment: video_2022-06-09T12_35_55_arena13 \n",
      "Condition: food_odor \n",
      "\n",
      "Iteration: 15 \n",
      "Experiment: video_2022-06-09T12_35_55_arena14 \n",
      "Condition: food_odor \n",
      "\n",
      "Iteration: 16 \n",
      "Experiment: video_2022-06-09T12_35_55_arena6 \n",
      "Condition: food_odor \n",
      "\n",
      "Iteration: 17 \n",
      "Experiment: video_2022-06-09T12_35_55_arena9 \n",
      "Condition: food_odor \n",
      "\n",
      "Iteration: 0 \n",
      "Experiment: video_2022-05-25T11_34_25_arena16 \n",
      "Condition: nothing \n",
      "\n",
      "Iteration: 1 \n",
      "Experiment: video_2022-05-25T12_07_57_arena8 \n",
      "Condition: nothing \n",
      "\n",
      "Iteration: 2 \n",
      "Experiment: video_2022-06-08T10_59_11_arena16 \n",
      "Condition: nothing \n",
      "\n",
      "Iteration: 3 \n",
      "Experiment: video_2022-06-08T10_59_11_arena4 \n",
      "Condition: nothing \n",
      "\n",
      "Iteration: 4 \n",
      "Experiment: video_2022-06-08T10_59_11_arena8 \n",
      "Condition: nothing \n",
      "\n",
      "Iteration: 5 \n",
      "Experiment: video_2022-06-08T11_21_49_arena13 \n",
      "Condition: nothing \n",
      "\n",
      "Iteration: 6 \n",
      "Experiment: video_2022-06-08T11_21_49_arena5 \n",
      "Condition: nothing \n",
      "\n",
      "Iteration: 7 \n",
      "Experiment: video_2022-06-08T11_21_49_arena9 \n",
      "Condition: nothing \n",
      "\n",
      "Iteration: 8 \n",
      "Experiment: video_2022-06-08T11_50_31_arena14 \n",
      "Condition: nothing \n",
      "\n",
      "Iteration: 9 \n",
      "Experiment: video_2022-06-08T11_50_31_arena15 \n",
      "Condition: nothing \n",
      "\n",
      "Iteration: 10 \n",
      "Experiment: video_2022-06-08T11_50_31_arena3 \n",
      "Condition: nothing \n",
      "\n",
      "Iteration: 11 \n",
      "Experiment: video_2022-06-09T12_04_14_arena13 \n",
      "Condition: nothing \n",
      "\n",
      "Iteration: 12 \n",
      "Experiment: video_2022-06-09T12_04_14_arena15 \n",
      "Condition: nothing \n",
      "\n",
      "Iteration: 13 \n",
      "Experiment: video_2022-06-09T12_35_55_arena3 \n",
      "Condition: nothing \n",
      "\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>has_aggression</th>\n",
       "      <th>ratio_frames</th>\n",
       "      <th>ratio_bouts</th>\n",
       "      <th>condition</th>\n",
       "      <th>experiment</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>True</td>\n",
       "      <td>0.004278</td>\n",
       "      <td>0.2</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-05-25T12_07_57_arena16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>True</td>\n",
       "      <td>0.002722</td>\n",
       "      <td>0.6</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-08T10_59_11_arena2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>True</td>\n",
       "      <td>0.003611</td>\n",
       "      <td>0.4</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-08T10_59_11_arena5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>True</td>\n",
       "      <td>0.005278</td>\n",
       "      <td>1.0</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-08T10_59_11_arena7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>True</td>\n",
       "      <td>0.007667</td>\n",
       "      <td>1.0</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-08T11_21_49_arena11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>True</td>\n",
       "      <td>0.001333</td>\n",
       "      <td>0.2</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-08T11_21_49_arena12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>True</td>\n",
       "      <td>0.008556</td>\n",
       "      <td>1.2</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-08T11_21_49_arena14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>True</td>\n",
       "      <td>0.002222</td>\n",
       "      <td>0.4</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-08T11_50_31_arena11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>True</td>\n",
       "      <td>0.000222</td>\n",
       "      <td>0.2</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-08T11_50_31_arena16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>True</td>\n",
       "      <td>0.002889</td>\n",
       "      <td>1.2</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-09T12_04_14_arena11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>True</td>\n",
       "      <td>0.045056</td>\n",
       "      <td>1.2</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-09T12_04_14_arena12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>True</td>\n",
       "      <td>0.021111</td>\n",
       "      <td>2.2</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-09T12_04_14_arena3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>True</td>\n",
       "      <td>0.010889</td>\n",
       "      <td>1.6</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-09T12_04_14_arena4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>True</td>\n",
       "      <td>0.008167</td>\n",
       "      <td>1.0</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-09T12_04_14_arena8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>True</td>\n",
       "      <td>0.001167</td>\n",
       "      <td>0.8</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-09T12_35_55_arena13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>True</td>\n",
       "      <td>0.009278</td>\n",
       "      <td>1.0</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-09T12_35_55_arena14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>True</td>\n",
       "      <td>0.010222</td>\n",
       "      <td>1.4</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-09T12_35_55_arena6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>True</td>\n",
       "      <td>0.008500</td>\n",
       "      <td>1.0</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-09T12_35_55_arena9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>False</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-05-25T11_34_25_arena16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>True</td>\n",
       "      <td>0.000944</td>\n",
       "      <td>0.4</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-05-25T12_07_57_arena8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>False</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-08T10_59_11_arena16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>True</td>\n",
       "      <td>0.005333</td>\n",
       "      <td>1.0</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-08T10_59_11_arena4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>True</td>\n",
       "      <td>0.001333</td>\n",
       "      <td>0.4</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-08T10_59_11_arena8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>False</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-08T11_21_49_arena13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>True</td>\n",
       "      <td>0.005167</td>\n",
       "      <td>0.4</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-08T11_21_49_arena5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>True</td>\n",
       "      <td>0.002500</td>\n",
       "      <td>0.4</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-08T11_21_49_arena9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>True</td>\n",
       "      <td>0.000889</td>\n",
       "      <td>0.4</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-08T11_50_31_arena14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>True</td>\n",
       "      <td>0.002667</td>\n",
       "      <td>0.6</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-08T11_50_31_arena15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>False</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-08T11_50_31_arena3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>True</td>\n",
       "      <td>0.000333</td>\n",
       "      <td>0.2</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-09T12_04_14_arena13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>True</td>\n",
       "      <td>0.007889</td>\n",
       "      <td>1.2</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-09T12_04_14_arena15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>True</td>\n",
       "      <td>0.004278</td>\n",
       "      <td>0.6</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-09T12_35_55_arena3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    has_aggression  ratio_frames  ratio_bouts  condition  \\\n",
       "0             True      0.004278          0.2  food_odor   \n",
       "1             True      0.002722          0.6  food_odor   \n",
       "2             True      0.003611          0.4  food_odor   \n",
       "3             True      0.005278          1.0  food_odor   \n",
       "4             True      0.007667          1.0  food_odor   \n",
       "5             True      0.001333          0.2  food_odor   \n",
       "6             True      0.008556          1.2  food_odor   \n",
       "7             True      0.002222          0.4  food_odor   \n",
       "8             True      0.000222          0.2  food_odor   \n",
       "9             True      0.002889          1.2  food_odor   \n",
       "10            True      0.045056          1.2  food_odor   \n",
       "11            True      0.021111          2.2  food_odor   \n",
       "12            True      0.010889          1.6  food_odor   \n",
       "13            True      0.008167          1.0  food_odor   \n",
       "14            True      0.001167          0.8  food_odor   \n",
       "15            True      0.009278          1.0  food_odor   \n",
       "16            True      0.010222          1.4  food_odor   \n",
       "17            True      0.008500          1.0  food_odor   \n",
       "18           False      0.000000          0.0    nothing   \n",
       "19            True      0.000944          0.4    nothing   \n",
       "20           False      0.000000          0.0    nothing   \n",
       "21            True      0.005333          1.0    nothing   \n",
       "22            True      0.001333          0.4    nothing   \n",
       "23           False      0.000000          0.0    nothing   \n",
       "24            True      0.005167          0.4    nothing   \n",
       "25            True      0.002500          0.4    nothing   \n",
       "26            True      0.000889          0.4    nothing   \n",
       "27            True      0.002667          0.6    nothing   \n",
       "28           False      0.000000          0.0    nothing   \n",
       "29            True      0.000333          0.2    nothing   \n",
       "30            True      0.007889          1.2    nothing   \n",
       "31            True      0.004278          0.6    nothing   \n",
       "\n",
       "                           experiment  \n",
       "0   video_2022-05-25T12_07_57_arena16  \n",
       "1    video_2022-06-08T10_59_11_arena2  \n",
       "2    video_2022-06-08T10_59_11_arena5  \n",
       "3    video_2022-06-08T10_59_11_arena7  \n",
       "4   video_2022-06-08T11_21_49_arena11  \n",
       "5   video_2022-06-08T11_21_49_arena12  \n",
       "6   video_2022-06-08T11_21_49_arena14  \n",
       "7   video_2022-06-08T11_50_31_arena11  \n",
       "8   video_2022-06-08T11_50_31_arena16  \n",
       "9   video_2022-06-09T12_04_14_arena11  \n",
       "10  video_2022-06-09T12_04_14_arena12  \n",
       "11   video_2022-06-09T12_04_14_arena3  \n",
       "12   video_2022-06-09T12_04_14_arena4  \n",
       "13   video_2022-06-09T12_04_14_arena8  \n",
       "14  video_2022-06-09T12_35_55_arena13  \n",
       "15  video_2022-06-09T12_35_55_arena14  \n",
       "16   video_2022-06-09T12_35_55_arena6  \n",
       "17   video_2022-06-09T12_35_55_arena9  \n",
       "18  video_2022-05-25T11_34_25_arena16  \n",
       "19   video_2022-05-25T12_07_57_arena8  \n",
       "20  video_2022-06-08T10_59_11_arena16  \n",
       "21   video_2022-06-08T10_59_11_arena4  \n",
       "22   video_2022-06-08T10_59_11_arena8  \n",
       "23  video_2022-06-08T11_21_49_arena13  \n",
       "24   video_2022-06-08T11_21_49_arena5  \n",
       "25   video_2022-06-08T11_21_49_arena9  \n",
       "26  video_2022-06-08T11_50_31_arena14  \n",
       "27  video_2022-06-08T11_50_31_arena15  \n",
       "28   video_2022-06-08T11_50_31_arena3  \n",
       "29  video_2022-06-09T12_04_14_arena13  \n",
       "30  video_2022-06-09T12_04_14_arena15  \n",
       "31   video_2022-06-09T12_35_55_arena3  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "aggression_df = pd.DataFrame()\n",
    "for condition in experiments.keys():\n",
    "    for h, experiment_path in enumerate(experiments[condition]):\n",
    "\n",
    "        experiment = os.path.basename(experiment_path).split('.')[0]\n",
    "        \n",
    "        print('Iteration:', h, '\\nExperiment:', experiment, '\\nCondition:', condition, '\\n')\n",
    "        \n",
    "        annotation_video = annotations.read(experiment_path)\n",
    "        aggression_events = annotation_video[1].events\n",
    "        n_events = len(aggression_events)\n",
    "\n",
    "        # In case there is aggression, do the necessary calculations.\n",
    "        if n_events > 0:\n",
    "            \n",
    "            ratio_frames = sum([aggression.duration for aggression in aggression_events]) / (5 * 60 * FPS)\n",
    "            ratio_bouts = n_events / 5\n",
    "            \n",
    "            aggression_data = pd.DataFrame({'has_aggression': True,\n",
    "                                            'ratio_frames': ratio_frames,\n",
    "                                            'ratio_bouts': ratio_bouts,\n",
    "                                            'condition': condition,\n",
    "                                            'experiment': experiment},\n",
    "                                            index=[h],\n",
    "                                           )\n",
    "\n",
    "        # If not, preset our dictionary with default values.\n",
    "        else:\n",
    "            aggression_data = pd.DataFrame({'has_aggression': False,\n",
    "                                            'ratio_frames': 0, \n",
    "                                            'ratio_bouts': 0,\n",
    "                                            'condition': condition,\n",
    "                                            'experiment': experiment},\n",
    "                                            index=[h],\n",
    "                                           )\n",
    "\n",
    "        # Concatenate all data together.\n",
    "        aggression_df = pd.concat([aggression_df, aggression_data], ignore_index=True)\n",
    "\n",
    "aggression_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Outlier Detection"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\t food_odor \n",
      "\n",
      "[10]\n",
      "Number data points considered outliers: 1\n",
      "Percent data points considered outliers: 5.556 %\n",
      "\n",
      "\t nothing \n",
      "\n",
      "[]\n",
      "Number data points considered outliers: 0\n",
      "Percent data points considered outliers: 0.0 %\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>has_aggression</th>\n",
       "      <th>ratio_frames</th>\n",
       "      <th>ratio_bouts</th>\n",
       "      <th>condition</th>\n",
       "      <th>experiment</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>True</td>\n",
       "      <td>0.004278</td>\n",
       "      <td>0.2</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-05-25T12_07_57_arena16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>True</td>\n",
       "      <td>0.002722</td>\n",
       "      <td>0.6</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-08T10_59_11_arena2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>True</td>\n",
       "      <td>0.003611</td>\n",
       "      <td>0.4</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-08T10_59_11_arena5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>True</td>\n",
       "      <td>0.005278</td>\n",
       "      <td>1.0</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-08T10_59_11_arena7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>True</td>\n",
       "      <td>0.007667</td>\n",
       "      <td>1.0</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-08T11_21_49_arena11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>True</td>\n",
       "      <td>0.001333</td>\n",
       "      <td>0.2</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-08T11_21_49_arena12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>True</td>\n",
       "      <td>0.008556</td>\n",
       "      <td>1.2</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-08T11_21_49_arena14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>True</td>\n",
       "      <td>0.002222</td>\n",
       "      <td>0.4</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-08T11_50_31_arena11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>True</td>\n",
       "      <td>0.000222</td>\n",
       "      <td>0.2</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-08T11_50_31_arena16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>True</td>\n",
       "      <td>0.002889</td>\n",
       "      <td>1.2</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-09T12_04_14_arena11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>True</td>\n",
       "      <td>0.021111</td>\n",
       "      <td>2.2</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-09T12_04_14_arena3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>True</td>\n",
       "      <td>0.010889</td>\n",
       "      <td>1.6</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-09T12_04_14_arena4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>True</td>\n",
       "      <td>0.008167</td>\n",
       "      <td>1.0</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-09T12_04_14_arena8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>True</td>\n",
       "      <td>0.001167</td>\n",
       "      <td>0.8</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-09T12_35_55_arena13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>True</td>\n",
       "      <td>0.009278</td>\n",
       "      <td>1.0</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-09T12_35_55_arena14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>True</td>\n",
       "      <td>0.010222</td>\n",
       "      <td>1.4</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-09T12_35_55_arena6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>True</td>\n",
       "      <td>0.008500</td>\n",
       "      <td>1.0</td>\n",
       "      <td>food_odor</td>\n",
       "      <td>video_2022-06-09T12_35_55_arena9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>False</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-05-25T11_34_25_arena16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>True</td>\n",
       "      <td>0.000944</td>\n",
       "      <td>0.4</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-05-25T12_07_57_arena8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>False</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-08T10_59_11_arena16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>True</td>\n",
       "      <td>0.005333</td>\n",
       "      <td>1.0</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-08T10_59_11_arena4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>True</td>\n",
       "      <td>0.001333</td>\n",
       "      <td>0.4</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-08T10_59_11_arena8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>False</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-08T11_21_49_arena13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>True</td>\n",
       "      <td>0.005167</td>\n",
       "      <td>0.4</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-08T11_21_49_arena5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>True</td>\n",
       "      <td>0.002500</td>\n",
       "      <td>0.4</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-08T11_21_49_arena9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>True</td>\n",
       "      <td>0.000889</td>\n",
       "      <td>0.4</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-08T11_50_31_arena14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>True</td>\n",
       "      <td>0.002667</td>\n",
       "      <td>0.6</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-08T11_50_31_arena15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>False</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-08T11_50_31_arena3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>True</td>\n",
       "      <td>0.000333</td>\n",
       "      <td>0.2</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-09T12_04_14_arena13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>True</td>\n",
       "      <td>0.007889</td>\n",
       "      <td>1.2</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-09T12_04_14_arena15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>True</td>\n",
       "      <td>0.004278</td>\n",
       "      <td>0.6</td>\n",
       "      <td>nothing</td>\n",
       "      <td>video_2022-06-09T12_35_55_arena3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    has_aggression  ratio_frames  ratio_bouts  condition  \\\n",
       "0             True      0.004278          0.2  food_odor   \n",
       "1             True      0.002722          0.6  food_odor   \n",
       "2             True      0.003611          0.4  food_odor   \n",
       "3             True      0.005278          1.0  food_odor   \n",
       "4             True      0.007667          1.0  food_odor   \n",
       "5             True      0.001333          0.2  food_odor   \n",
       "6             True      0.008556          1.2  food_odor   \n",
       "7             True      0.002222          0.4  food_odor   \n",
       "8             True      0.000222          0.2  food_odor   \n",
       "9             True      0.002889          1.2  food_odor   \n",
       "11            True      0.021111          2.2  food_odor   \n",
       "12            True      0.010889          1.6  food_odor   \n",
       "13            True      0.008167          1.0  food_odor   \n",
       "14            True      0.001167          0.8  food_odor   \n",
       "15            True      0.009278          1.0  food_odor   \n",
       "16            True      0.010222          1.4  food_odor   \n",
       "17            True      0.008500          1.0  food_odor   \n",
       "18           False      0.000000          0.0    nothing   \n",
       "19            True      0.000944          0.4    nothing   \n",
       "20           False      0.000000          0.0    nothing   \n",
       "21            True      0.005333          1.0    nothing   \n",
       "22            True      0.001333          0.4    nothing   \n",
       "23           False      0.000000          0.0    nothing   \n",
       "24            True      0.005167          0.4    nothing   \n",
       "25            True      0.002500          0.4    nothing   \n",
       "26            True      0.000889          0.4    nothing   \n",
       "27            True      0.002667          0.6    nothing   \n",
       "28           False      0.000000          0.0    nothing   \n",
       "29            True      0.000333          0.2    nothing   \n",
       "30            True      0.007889          1.2    nothing   \n",
       "31            True      0.004278          0.6    nothing   \n",
       "\n",
       "                           experiment  \n",
       "0   video_2022-05-25T12_07_57_arena16  \n",
       "1    video_2022-06-08T10_59_11_arena2  \n",
       "2    video_2022-06-08T10_59_11_arena5  \n",
       "3    video_2022-06-08T10_59_11_arena7  \n",
       "4   video_2022-06-08T11_21_49_arena11  \n",
       "5   video_2022-06-08T11_21_49_arena12  \n",
       "6   video_2022-06-08T11_21_49_arena14  \n",
       "7   video_2022-06-08T11_50_31_arena11  \n",
       "8   video_2022-06-08T11_50_31_arena16  \n",
       "9   video_2022-06-09T12_04_14_arena11  \n",
       "11   video_2022-06-09T12_04_14_arena3  \n",
       "12   video_2022-06-09T12_04_14_arena4  \n",
       "13   video_2022-06-09T12_04_14_arena8  \n",
       "14  video_2022-06-09T12_35_55_arena13  \n",
       "15  video_2022-06-09T12_35_55_arena14  \n",
       "16   video_2022-06-09T12_35_55_arena6  \n",
       "17   video_2022-06-09T12_35_55_arena9  \n",
       "18  video_2022-05-25T11_34_25_arena16  \n",
       "19   video_2022-05-25T12_07_57_arena8  \n",
       "20  video_2022-06-08T10_59_11_arena16  \n",
       "21   video_2022-06-08T10_59_11_arena4  \n",
       "22   video_2022-06-08T10_59_11_arena8  \n",
       "23  video_2022-06-08T11_21_49_arena13  \n",
       "24   video_2022-06-08T11_21_49_arena5  \n",
       "25   video_2022-06-08T11_21_49_arena9  \n",
       "26  video_2022-06-08T11_50_31_arena14  \n",
       "27  video_2022-06-08T11_50_31_arena15  \n",
       "28   video_2022-06-08T11_50_31_arena3  \n",
       "29  video_2022-06-09T12_04_14_arena13  \n",
       "30  video_2022-06-09T12_04_14_arena15  \n",
       "31   video_2022-06-09T12_35_55_arena3  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "corrected_ratio_frames = pd.DataFrame()\n",
    "\n",
    "for condition in condition_order:\n",
    "\n",
    "    print('\\n\\t', condition, '\\n')\n",
    "\n",
    "    try:\n",
    "        dataset = aggression_df.query('condition==\"' + condition + '\"')['ratio_frames']\n",
    "\n",
    "        outlier_positions = helpers.check_outliers(dataset)\n",
    "        print(outlier_positions)\n",
    "\n",
    "        fresh_dataset = pd.DataFrame(helpers.remove_outliers(dataset, indices=outlier_positions))\n",
    "        fresh_dataset['condition'] = condition\n",
    "\n",
    "        corrected_ratio_frames = pd.concat([corrected_ratio_frames, fresh_dataset], axis=0)\n",
    "        \n",
    "    except ValueError as error:\n",
    "        print(error)\n",
    "\n",
    "aggression_df = aggression_df.loc[corrected_ratio_frames.index]\n",
    "aggression_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Aggression Rate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>condition</th>\n",
       "      <th>ratio_frames</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>food_odor</td>\n",
       "      <td>0.004278</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>food_odor</td>\n",
       "      <td>0.002722</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>food_odor</td>\n",
       "      <td>0.003611</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>food_odor</td>\n",
       "      <td>0.005278</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>food_odor</td>\n",
       "      <td>0.007667</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   condition  ratio_frames\n",
       "0  food_odor      0.004278\n",
       "1  food_odor      0.002722\n",
       "2  food_odor      0.003611\n",
       "3  food_odor      0.005278\n",
       "4  food_odor      0.007667"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratio_frames_df = aggression_df.copy()[['condition', 'ratio_frames']]\n",
    "ratio_frames_df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Statistics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\t nothing \n",
      "\n",
      "Shapiro's Test: group 1 IS NOT normally distributed.\n",
      "D'Agostino's Test: group 1 IS NOT normally distributed.\n",
      "Shapiro's Test: group 2 IS NOT normally distributed.\n",
      "D'Agostino's Test: group 2 IS normally distributed.\n",
      "Levene's Test for non-normally distributed samples:\n",
      "  p-value = 0.066345\n",
      "  All groups were sampled from populations with IDENTICAL variances.\n",
      "\n",
      "Mann-Whitney p-value: 0.002540657520410971 \n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "c:\\program files\\python37\\lib\\site-packages\\scipy\\stats\\stats.py:1535: UserWarning: kurtosistest only valid for n>=20 ... continuing anyway, n=17\n",
      "  \"anyway, n=%i\" % int(n))\n",
      "c:\\program files\\python37\\lib\\site-packages\\scipy\\stats\\stats.py:1535: UserWarning: kurtosistest only valid for n>=20 ... continuing anyway, n=14\n",
      "  \"anyway, n=%i\" % int(n))\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'nothing': 0.002540657520410971}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratio_frames_pvalues = {}\n",
    "\n",
    "control = ratio_frames_df.query('condition==\"food_odor\"')['ratio_frames']\n",
    "\n",
    "for condition in condition_order[1:]:\n",
    "\n",
    "    print('\\n\\t', condition, '\\n')\n",
    "\n",
    "    try:\n",
    "        test = ratio_frames_df.query('condition==\"' + condition + '\"')['ratio_frames']\n",
    "\n",
    "        temp_values = {'control': control, 'test': test}\n",
    "\n",
    "        pvalue_condition = helpers.run_statistics(temp_values)\n",
    "\n",
    "        ratio_frames_pvalues[condition] = pvalue_condition\n",
    "        \n",
    "    except ValueError as error:\n",
    "        print(error)\n",
    "    \n",
    "ratio_frames_pvalues"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Effect Size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nothing\n",
      "Medium Effect: -0.7842105263157895 \n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'nothing': -0.7842105263157895}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratio_frames_effect_sizes = {}\n",
    "\n",
    "control = ratio_frames_df.query('condition==\"food_odor\"')['ratio_frames']\n",
    "\n",
    "for condition in condition_order[1:]:\n",
    "    \n",
    "    print(condition)\n",
    "    \n",
    "    test = ratio_frames_df.query('condition==\"' + condition +'\"')['ratio_frames']\n",
    "\n",
    "    median_diff = helpers.get_effect_size(control, test, method='median_diff')\n",
    "\n",
    "    ratio_frames_effect_sizes[condition] = median_diff\n",
    "    \n",
    "ratio_frames_effect_sizes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAMIAAAFHCAYAAADz65PuAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nO3deXxM1//H8ddkX2WPhEgQQWQ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9/P3Z2dkybNo3u3btrVEObNm2YNWsWgwcPpkaNGnz66aesXr2aRo0aaXVd/vJwrS4uLjRr1oz27dvz2WefYWJiwvr16/nxxx+pUaMGwcHBjB07lk6dOlWoFk3IAccliWe4RZCkh8kgSBIyCJIEyCBIEiCDIEmADIIkATIIkgTIIEgSAP8PMREKJMPJVyYAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 180x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Initialize figure.\n",
    "n_conditions = ratio_frames_df['condition'].nunique()\n",
    "figure, axis = plt.subplots(figsize=(1.25*n_conditions, 4))\n",
    "\n",
    "# Draw the boxplot.\n",
    "sns.boxplot(x='condition',\n",
    "            y='ratio_frames',\n",
    "            data=ratio_frames_df,\n",
    "            order=condition_order,\n",
    "            palette=['steelblue', '#5e6472'],\n",
    "            width=0.6,\n",
    "            showfliers=False,\n",
    "            boxprops={'edgecolor': INK},\n",
    "            medianprops={'color': INK},\n",
    "            whiskerprops={'color': INK},\n",
    "            capprops={'color': INK}\n",
    "           )\n",
    "\n",
    "# Draw the swarmplot.\n",
    "sns.swarmplot(x='condition',\n",
    "              y='ratio_frames',\n",
    "              data=ratio_frames_df,\n",
    "              order=condition_order,\n",
    "              palette=['steelblue', '#5e6472'],\n",
    "              linewidth=0.75,\n",
    "              edgecolor=INK\n",
    "             )\n",
    "\n",
    "# Figure and axes formatting.\n",
    "axis.set_xlabel('24h-mated females', labelpad=75)\n",
    "axis.set_xticklabels([''])\n",
    "axis.set_ylabel('Aggression Rate (%)')\n",
    "axis.set_ylim(0, 0.025)\n",
    "axis.set_yticks(np.arange(0, 0.025+0.001, 0.005))\n",
    "axis.set_yticklabels([round(y*100, 2) for y in axis.get_yticks()])\n",
    "\n",
    "# Table definition.\n",
    "row1 = [str(ratio_frames_df.query('condition==\"'+condition+'\"').shape[0]) for condition in condition_order]\n",
    "row2 = ['Food\\nodour', 'Without\\nFood odour']\n",
    "cell_text = np.array([row1, row2])\n",
    "\n",
    "row_labels = ['n =', '']\n",
    "summary_table = axis.table(cellText= cell_text,\n",
    "                           cellLoc='center',\n",
    "                           rowLabels=row_labels,\n",
    "                           rowLoc='center',\n",
    "                           colLoc='center'\n",
    "                          )\n",
    "\n",
    "summary_table.auto_set_font_size(False)\n",
    "summary_table.set_fontsize(11)\n",
    "\n",
    "properties = summary_table.properties()\n",
    "table_cells = properties['children']\n",
    "for cell in table_cells:\n",
    "    cell.set_height(0.12)\n",
    "    cell.set_alpha(0)\n",
    "\n",
    "# Draw statistical result.\n",
    "for p, condition in enumerate(condition_order[1:]):\n",
    "    sig_height = 6 if (ratio_frames_pvalues.get(condition, 'NaN') == 'NaN') or (ratio_frames_pvalues.get(condition, 'NaN') >= 0.05) else 2\n",
    "    helpers.plot_stattest_result(ax=axis,\n",
    "                                 x1=p+1,\n",
    "                                 x2=p+1,\n",
    "                                 p_value=ratio_frames_pvalues.get(condition, 'NaN'),\n",
    "                                 y=0.023,\n",
    "                                 ticksize=0,\n",
    "                                 xytext=(0,sig_height),\n",
    "                                 fontsize=13,\n",
    "                                 color=INK,\n",
    "                                 connector_color=INK\n",
    "                                )\n",
    "\n",
    "# Saving parameters.\n",
    "filename = 'aggression_rate_5mins_territory_24h_mated'\n",
    "plt.savefig(os.path.join(savepath, filename))\n",
    "\n",
    "plt.show()\n",
    "plt.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
